<%-- 
    Document   : rssortuser
    Created on : Nov 2, 2011, 2:05:58 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.NhomNhanVien,Beans.ThamSoHT,Models.ThamSoHT_Model, Models.NhanVien_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'persondecentra', 'order', 'notice', 'rightmsg',  'groupdecentra', 'status', 'enable', 'disable', 'all', 'nameofuser', 'groupuser', 'startdate', 'userlist' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String disable = mdsts[1].getTenTS();
            String enable = mdsts[2].getTenTS();
            String groupdecentra = mdsts[3].getTenTS();
            String groupuser = mdsts[4].getTenTS();
            String nameofuser = mdsts[5].getTenTS();
            String notice = mdsts[6].getTenTS();
            String order = mdsts[7].getTenTS();
            String persondecentra = mdsts[8].getTenTS();
            String rightmsg = mdsts[9].getTenTS();
            String startdate = mdsts[10].getTenTS();
            String status = mdsts[11].getTenTS();
            String userlist = mdsts[12].getTenTS();
            String msgright = notice + "/" + rightmsg;

            Vector v = (Vector) request.getAttribute("DSNV");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String sx3 = "";
            String sx4 = "";
            String ud1 = "";
            String ud2 = "";
            String ud3 = "";
            String ud4 = "";
            if(sapxep.equals("desc")){
                   sx1 = "down";
                   sx2 = "down";
                   sx3 = "down";
                   sx4 = "down";
                   ud1 = "down1";
                   ud4 = "down2";
                   ud2 = "down1";
                   ud3 = "down1";
            }            
            else if(sapxep.equals("asc") && test.equals("1")){
                    sx1 = "up";
                    sx2 = "down";
                    sx3 = "down";
                    sx4 = "down";
                    ud1 = "up1";
                    ud2 = "down1";
                    ud3 = "down1";
                    ud4 = "down2";
            }
            else if(sapxep.equals("asc") && test.equals("2")){
                    sx1 = "down";
                    sx2 = "up";
                    sx3 = "down";
                    sx4 = "down";
                    ud1 = "down1";
                    ud2 = "up1";
                    ud3 = "down1";
                    ud4 = "down2";
            }            
             else if(sapxep.equals("asc") && test.equals("3")){
                    sx1 = "down";
                    sx2 = "down";
                    sx3 = "up";
                    sx4 = "down";
                    ud1 = "down1";
                    ud2 = "down1";
                    ud3 = "up1";
                    ud4 = "down2";
             }
             else if(sapxep.equals("asc") && test.equals("4")){
                    sx1 = "down";
                    sx2 = "down";
                    sx3 = "down";
                    sx4 = "up";
                    ud1 = "down1";
                    ud2 = "down1";
                    ud3 = "down1";
                    ud4 = "up2";
             }
%>
<script type="text/javascript">
    $(function(){       
        $('#datepicker2').datepicker($.datepicker.regional['vi']);
        $( "#datepicker2" ).datepicker( "option", "dateFormat","dd/mm/yy");
     });
</script>
    
        <div class="title">
        <%=userlist%><a href="#" lang="<%=msgright%>" onclick="PhanQuyenNhom(this.lang)" style=" float: right; margin-right: 0px; margin-top: -9px;" title="<%=groupdecentra %>"><img alt="" src="../images/group.png"></a>
    </div>
        <div class="content">
            <form name="dsban" action="">
                <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr>
                            <th style="width: 9%;"><%=order%></th>
                            <th style=" width: 20%;">
                                <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1 %>" lang="<%=msgright%>"   name="1" onclick="SortHoTenNV(this.name, this.className, this.lang)">
                                    <div style="float:left"><%=nameofuser%></div>
                                    <div style=" margin-right: 45px;" id="sortkv1" class="<%=ud1 %>"></div>
                                </a>
                            </th>
                            <th style=" width: 22%;">
                                <a href="#" id="titledskv2" style="margin-top: 5px;" class="<%=sx2 %>" lang="<%=msgright%>"   name="1" onclick="SortNgayVaoLam(this.name, this.className, this.lang)">
                                    <div style="float:left"><%=startdate%></div>
                                    <div style=" margin-right: 45px;" id="sortkv2" class="<%=ud2 %>"></div>
                                </a>
                            </th>
                            <th style=" width: 24%;">
                                <a href="#" id="titledskv3" style="margin-top: 5px;" class="<%=sx3 %>" lang="<%=msgright%>"  name="1" onclick="SortNhomNV(this.name, this.className, this.lang)">
                                    <div style="float:left"><%=groupuser %></div>
                                    <div style=" margin-right: 60px;" id="sortkv3" class="<%=ud3 %>"></div>
                                </a>

                            </th>
                            <th style="margin-top: 2px; width: 20%;">
                                <a href="#" id="titledskv4" class="<%=sx4 %>" lang="<%=msgright%>"  name="1" onclick="SortTTNV(this.name, this.className, this.lang)">
                                    <div><%=status %></div>
                                    <div >
                                        <div id="sortkv4" class="<%=ud4 %>"></div>                                        
                                    </div>
                                </a>                                
                            </th>
                            <th></th>
                        </tr>
                        <tr id="searchNV" >
                        <th><img onclick="SearchUser( this.alt, this.lang)" lang="<%=msgright%>" style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png"></th>
                        <th >
                            <input type="textbox" style=" width: 120px;" name="HOTEN"  class="HOTEN text" >
                        </th>
                        <th >
                            <input type="textbox" style=" width: 125px;" id="datepicker2"  name="NGAYVAOLAM" class="NGAYVAOLAM text" >
                        </th>
                        <th>
                            <select class="selectNHOMNHANVIEN" id="1" name="NHOMNHANVIEN" lang="<%=msgright%>"  onchange="SearchUser( this.id, this.lang)">
                                <option value="all"><%= all%></option>
                                <%
                                                NhomNhanVien[] dsn = NhanVien_Model.DanhSachNhom(langid);
                                                for (int k = 0; k < dsn.length; k++) {%>
                                <option value="<%=dsn[k].getMaNNV()%>"><%=dsn[k].getTenNNV()%></option>
                                <%  }
                                %>
                            </select>
                        </th>
                        <th>
                            <select class="selectTINHTRANG" id="1" name="TINHTRANG" lang="<%=msgright%>"  onchange="SearchUser( this.id, this.lang)">
                                <option value="all"><%= all%></option>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                            </select>
                        </th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>                        
                       <%
                                    for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                                        Beans.NhanVien nv = (Beans.NhanVien) v.elementAt(i);
                        %>
                        <tr>
                            <td class="STT"><%= i + 1%></td>
                            <td><a href="#" name="<%=nv.getMaNV()%>" lang="<%=msgright%>"  onclick="UpdateDetail( this.name, this.lang)"><%=nv.getHoTen()%></a></td>
                            <td ><%=nv.getNgayVaoLam() %></td>
                            <td>
                                <select  class="<%= nv.getMaNV() %>" lang="<%=msgright%>"  onchange="UpdateNNV(this.value, this.className, this.lang)">
                                    <option value="<%=nv.getMaNNV() %>"><%=NhanVien_Model.LayTenNhom(nv.getMaNNV(), langid) %></option>
                                <%
                                    NhomNhanVien[] dsnn = NhanVien_Model.DSNhom(nv.getMaNNV(), langid);
                                    for(int k=0; k<dsnn.length; k++){%>
                                    <option value="<%=dsnn[k].getMaNNV() %>"><%=dsnn[k].getTenNNV() %></option>
                                <%  }
                                %>
                                </select>
                            </td>

                            <td>
                                <select  class="<%= nv.getMaNV() %>" lang="<%=msgright%>"  onchange="UpdateStatusNV(this.value,  this.className, this.lang)">
                                    <%
                                           if (nv.getTinhTrang() == 1) {%>
                                    <option value="1"><%= enable%></option>
                                    <option value="0"><%= disable%></option>
                                    <%  } else {%>
                                    <option value="0"><%= disable%></option>
                                    <option value="1"><%= enable%></option>
                                    <%  }
                                    %>
                                </select>
                            </td>
                            <td><a href="#" class="<%=nv.getMaNV() %>" title="<%=persondecentra%>" lang="<%=msgright%>" onclick="PhanQuyenCaNhan(this.className, this.lang)" ><img alt="" style=";"  src="../images/edituser.png"></a></td>
                        </tr>
                        <%  }
                        %>
                    </tbody>
                    </table>
                                    <div class="pagination">
                    <%
                                int trang = 1;
                                if (item > 1) {
                                    trang = item - 1;
                                }
                    %>
                    <%
                                if (vsize > 6) {%>
                    <%
                        if(sortkv.equals("tennv")){%>
                        <a href="#" id="<%=sort %>" class="prev" lang="<%=msgright%>" name="<%= trang%>" onclick="SortHoTenNV(this.name, this.id, this.lang)">«</a>
                    <%  }
                        else if(sortkv.equals("ngayvaolam")){%>
                        <a href="#" id="<%=sort %>" class="prev" lang="<%=msgright%>"  name="<%= trang%>" onclick="SortNgayVaoLam(this.name, this.id, this.lang)">«</a>
                    <%  }
                        else if(sortkv.equals("nhomnv")){%>
                        <a href="#" id="<%=sort %>" class="prev" lang="<%=msgright%>" name="<%= trang%>" onclick="SortNhomNV(this.name, this.id, this.lang)">«</a>
                    <%  }else{%>
                        <a href="#" id="<%=sort %>" class="prev" lang="<%=msgright%>" name="<%= trang%>" onclick="SortTTNV(this.name, this.id, this.lang)">«</a>
                    <%  }
                    %>

                    <%
                                                for (int c = 1; c <= numpage; c++) {

                                                    if (c != item) {
                    %>
                    <%
                        if(sortkv.equals("tennv")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" name="<%= c%>" onclick="SortHoTenNV(this.name, this.id, this.lang)" ><%= c%></a>
                    <%  }
                        else if(sortkv.equals("ngayvaolam")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" name="<%= c%>" onclick="SortNgayVaoLam(this.name, this.id, this.lang)" ><%= c%></a>
                    <%  }
                        else if(sortkv.equals("nhomnv")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" name="<%= c%>" onclick="SortNhomNV(this.name, this.id, this.lang)" ><%= c%></a>
                    <%  }else{%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" name="<%= c%>" onclick="SortTTNV(this.name, this.id, this.lang)" ><%= c%></a>
                    <%  }

                    %>

                    <% } else {%><a class="current"> <%= c%></a> <% }

                                                }
                    %>
                    <%
                                                if (item + 1 <= numpage) {
                                                    trang = item + 1;
                                                } else {
                                                    trang = item;
                                                }
                    %>
                    <%
                        if(sortkv.equals("tennv")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortHoTenNV(this.name, this.id, this.lang)">»</a>
                    <%  }
                        else if(sortkv.equals("ngayvaolam")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortNgayVaoLam(this.name, this.id, this.lang)">»</a>
                    <%  }
                        else if(sortkv.equals("nhomnv")){%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortNhomNV(this.name, this.id, this.lang)">»</a>
                    <%  }else{%>
                        <a href="#" id="<%=sort %>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortTTNV(this.name, this.id, this.lang)">»</a>
                    <%  }
                    %>


                    <%  }
                    %>
                </div>
                </form>
        </div>
    
